package com.improve.frame.db.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.improve.frame.db.mapper.BaseMapper;
import com.improve.frame.db.service.BaseService;

import java.util.Map;

/**
 * @Description
 *      Service基础实现类
 * @Author wzxing918
 * @Date 2021-03-31
 * @Version 1.0.0
 **/
public class BaseServiceImpl<M extends BaseMapper<T>, T> extends ServiceImpl<M, T> implements BaseService<T> {

    @Override
    public IPage<T> page(T entity, Integer pageNo, Integer pageSize) {
        return this.page(new Page<>(pageNo, pageSize), new QueryWrapper<>(entity));
    }

    @Override
    public Page<T> selectComplex(Map<String, Object> map, int pageIndex, int pageSize) {
        Page<T> page = new Page<>(pageIndex, pageSize);
        page.setRecords(getBaseMapper().selectComplex(page,map));
        return page;
    }
}